<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>

<body>
  <img src="blankface.jpg" width="161" height="350" alt="" style="float:right" />
  <img name="elvislogo" src="elvislogo.gif" width="229" height="32" border="0" alt="Make Me Elvis" />
  <p>Please select the email addresses to delete from the email list and click Remove.</p>
  <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  		<?php
  			$dbc=mysqli_connect('localhost','root','root','elvis_store') or die('Error connecting to MySQL server.');
  			mysqli_query($dbc,'set names "utf8"'); 
  			
  			if(isset($_POST['submit'])){
  				foreach ($_POST['todelete'] as $delete_id){
  					$query="Delete from email_list where id = $delete_id";
  					mysqli_query($dbc,$query)or die('Error querying database.');
  					echo "Customer $delete_id  removed.<br/>";
  				}
  				
  			}
  				$query ="select * from email_list";
  				$result=mysqli_query($dbc,$query)or die(mysqli_errno());
  				while($row = mysqli_fetch_array($result)){
  					echo '<input type="checkbox" value="'. $row['id'] .'" name="todelete[]" />';
  					echo ' '.$row['id'];
  					echo ' '.$row['first_name'];
  					echo ' '.$row['last_name'];
  					echo ' '.$row['email'];
  					echo '<br/>';
  				}
  				
  			mysqli_close($dbc);
  		?>
  		
  		<input type="submit" name="submit" value="Remove" />
  	
  </form>
  
</body>
</html>